<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: ZhuoWen
  Date: 2022/4/24
  Time: 15:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--
遍历1到10
begin属性设置开始的索引
end属性设置结束的索引
var属性表示循环的变量（也是当前正在遍历到的数据）
--%>
<table>
<C:forEach begin="1" end="10" var="i">
    <tr>
        <td>第${i}行</td>
    </tr>
</C:forEach>
</table>

<hr>
<%--
    遍历Object数组
    item 表示遍历的数据源（遍历的集合数据）
    var 表示当前遍历到的数据
--%>
<%
    request.setAttribute("arr",new String[]{"张三","李四","王五","赵六"});
%>
<c:forEach items="${requestScope.arr}" var="item">
    ${item}<br>
</c:forEach>

<hr>
<%
    Map<String,Object> map = new HashMap<String, Object>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");
// for ( Map.Entry<String,Object> entry : map.entrySet()) {
// }
    request.setAttribute("map", map);
%>
<c:forEach items="${ requestScope.map }" var="entry">
    <h1>${entry.key} = ${entry.value}</h1>
</c:forEach>
</body>
</html>
